import logging

from flask import Blueprint, jsonify, request

# 获取日志记录器
logger = logging.getLogger(__name__)
rule_bp = Blueprint('rule', __name__, url_prefix='/api')

@rule_bp.route('/rule', methods=['POST', 'GET'])
def rules():

    current = request.args.get('current')
    pageSize = request.args.get('pageSize')
    name = request.args.get('name')
    desc = request.args.get('desc')
    logger.info(f"current: {current}, pageSize: {pageSize}, name: {name}, desc: {desc}")
    return jsonify({
      "data": [
        {
          "key": 99,
          "disabled": True,
          "href": "https://ant.design",
          "avatar": "https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png",
          "name": "TradeCode 99",
          "owner": "曲丽丽",
          "desc": "这是一段描述",
          "callNo": 503,
          "status": "0",
          "updatedAt": "2022-12-06T05:00:57.040Z",
          "createdAt": "2022-12-06T05:00:57.040Z",
          "progress": 81
        },
        {
          "key": 98,
          "disabled": False,
          "href": "https://ant.design",
          "avatar": "https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png",
          "name": "TradeCode 98",
          "owner": "曲丽丽",
          "desc": "这是一段描述",
          "callNo": 164,
          "status": "1",
          "updatedAt": "2022-12-06T05:00:57.040Z",
          "createdAt": "2022-12-06T05:00:57.040Z",
          "progress": 12
        },

      ],
      "total": 250,
      "success": True,
      "pageSize": 20,
      "current": 1
    })

@rule_bp.route('/issues', methods=['GET', 'POST'])
def issues():
    return jsonify({
      "data": [
          {
              "id": 624748504,
              "number": 6689,
              "title": "🐛 [BUG]yarn install命令 antd2.4.5会报错",
              "labels": [
                  {
                      "name": "bug",
                      "color": "error"
                  }
              ],
              "state": "open",
              "locked": False,
              "comments": 1,
              "created_at": 1590486176000,
              "updated_at": 1590487382000,
              "closed_at": None,
              "author_association": "NONE",
              "user": "chenshuai2144",
              "avatar": "https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png"
          },
          {
              "id": 624691229,
              "number": 6688,
              "title": "🐛 [BUG]无法创建工程npm create umi",
              "labels": [
                  {
                      "name": "bug",
                      "color": "error"
                  }
              ],
              "state": "open",
              "locked": False,
              "comments": 0,
              "created_at": 1590481162000,
              "updated_at": 1590481162000,
              "closed_at": None,
              "author_association": "NONE",
              "user": "chenshuai2144",
              "avatar": "https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png"
          },
          {
              "id": 624674790,
              "number": 6685,
              "title": "🧐 [问题] build 后还存在 es6 的代码（Umi@2.13.13）",
              "labels": [
                  {
                      "name": "question",
                      "color": "success"
                  }
              ],
              "state": "open",
              "locked": False,
              "comments": 0,
              "created_at": 1590479665000,
              "updated_at": 1590479665000,
              "closed_at": None,
              "author_association": "NONE",
              "user": "chenshuai2144",
              "avatar": "https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png"
          },
          {
              "id": 624620220,
              "number": 6683,
              "title": "2.3.1版本如何在业务页面修改头部状态",
              "labels": [
                  {
                      "name": "question",
                      "color": "success"
                  }
              ],
              "state": "open",
              "locked": False,
              "comments": 2,
              "created_at": 1590472704000,
              "updated_at": 1590477459000,
              "closed_at": None,
              "author_association": "NONE",
              "user": "chenshuai2144",
              "avatar": "https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png"
          },
          {
              "id": 624592471,
              "number": 6682,
              "title": "hideChildrenInMenu设置后，子路由找不到了",
              "labels": [
                  {
                      "name": "bug",
                      "color": "error"
                  }
              ],
              "state": "open",
              "locked": False,
              "comments": 2,
              "created_at": 1590467159000,
              "updated_at": 1590480051000,
              "closed_at": None,
              "author_association": "NONE",
              "user": "chenshuai2144",
              "avatar": "https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png"
          }
      ],
      "page": 1,
      "success": True,
      "total": 30
  })